#pragma once

#include <QMutex>
#include <QMutexLocker>
#include <QObject>
#include <QPointer>
#include <QVariantMap>
#include "rviz_custom_plugins/models/project.h"
#include "rviz_custom_plugins/models/poses.h"
#include "rviz_custom_plugins/models/flyzones.h"
#include "rviz_custom_plugins/models/planes.h"
#include "rviz_custom_plugins/models/point_normals.h"


using rviz_custom_plugins::models::Poses;
using rviz_custom_plugins::models::Flyzones;
using rviz_custom_plugins::models::Planes;
using rviz_custom_plugins::models::PointNormals;
using rviz_custom_plugins::models::Project;



namespace rviz_custom_plugins
{

namespace utils
{


class ProjectManager: public QObject
{
    Q_OBJECT

public:

    // 获取单例实例（线程安全）
    static QPointer<ProjectManager> getInstance();

    // 创建项目
    bool createProject(QString folder);
    // 打开项目
    bool openProject(QString folder);
    // 保存项目
    bool saveProject();
    // 关闭项目
    bool closeProject();

signals:
    void projectCreated(QSharedPointer<QVariantMap> projectData);
    void projectOpened(QSharedPointer<QVariantMap> projectData);
    void projectSaved(QSharedPointer<QVariantMap> projectData);
    void projectClosed(QSharedPointer<QVariantMap> projectData);

private:
    ProjectManager() = default;
    ProjectManager(const ProjectManager&) = delete;
    ProjectManager& operator=(const ProjectManager&) = delete;

    static QPointer<ProjectManager> instance;
    static QMutex mutex;

    QString projectFolder;

    QSharedPointer<QVariantMap> projectData;

    void loadProjectData();

    void saveProjectData();

};


}

}